<?php
/*********************************************************
author			Henson
date			2011-12-12
function		教程页的顶踩数统计
*********************************************************/

include_once("../common.inc.php");
include_once( _INC_PATH."database.php" );
include_once( _INC_PATH."global.php" );

$db = new database();
$sql = "SELECT count(id) as total,type,id FROM `tbl_pj` group by id,type";
$db->setQuery($sql);
$rows = $db->loadAssocList();

foreach($rows as $key=>$value)
{
	$id = $value['id'];
	$col = ($value['type'] == "up" ? "upNum" : "downNum");
	$num = intval($value['total']);
	$sql = "update tbl_tech set $col=$col+$num where id='$id'";
	$db->query($sql);
}

$db->query("truncate tbl_pj");

echo "finish";
die;
?>